<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<script src="./js/vue.js"></script>
<body>
    <div class="box">
        <h1 ref="test">{{msg}}</h1>
        <button @click="handler">获取标签内容</button>
    </div>
    <script>
        const vm = new Vue({
            el:'.box',
            data:{
                msg:'任远想想什么呢？'
            },
            methods: {
                handler(){
                    this.msg = '孙伟在想什么？'
                    // 获取的是DOM还未更新的旧值
                    /* console.log(this.$refs.test.innerHTML);
                    // 获取的是在DOM更新结束后的值
                    this.$nextTick(()=>{
                        console.log(this.$refs.test.innerHTML)
                    }) */
                }
            },
        })
        vm.msg = '思哲睡着了吗？思哲说没有';
        console.log(vm.$refs.test.innerHTML);
        //全局的方法
        Vue.nextTick(()=>{
            console.log(vm.$refs.test.innerHTML);
        })
    </script>
</body>
</html>